<HTML><HEAD><TITLE>impose_domain(?Var, ?DomVar)</TITLE>
</HEAD><BODY>[ <A HREF="index.html">library(ic_kernel)</A> | <A HREF="../../index.html">Reference Manual</A> | <A HREF="../../fullindex.html">Alphabetic Index</A> ]
<H1>impose_domain(?Var, ?DomVar)</H1>
Restrict (if required) the domain of Var t othe domain of DomVar.
<DL>
<DT><EM>Var</EM></DT>
<DD>Variable or number
</DD>
<DT><EM>DomVar</EM></DT>
<DD>Variable or number
</DD>
</DL>
<H2>Description</H2>
<P>
   Primitive for restricting the domain of Var to the domain of DomVar.
   Any values in the domain of Var, which are not also in the domain of
   DomVar, are removed.  DomVar remains unaffected.  
   The domain update on Var may fail (when the update empties the domain),
   succeed (possibly updating the variable's domain), or instantiate the
   variable (in the case where the domain gets restricted to a singleton
   value).  Note that if DomVar's type is integer, the integrality will
   be imposed on Var as well as the domain values.</P><P>

   Note that this predicate is intended for use only in implementing
   constraint propagators, and should not be called from ordinary user code.
   The waking behaviour is the same as discussed for impose_min/2 and
   impose_max/2.  Apart from this, the effect is similar to unifying
   Var with a copy of DomVar.
   </P>

<H2>Examples</H2>
<PRE>    ?- X::1..9, Y::5..7, impose_domain(X, Y).
    X = X{5 .. 7}
    Y = Y{5 .. 7}
    Yes (0.00s cpu)

    ?- X::1..9, impose_domain(X, 7).
    X = 7
    Yes (0.00s cpu)

    ?- X::1..9, Y::4.1..7.5, impose_domain(X, Y).
    X = X{5 .. 7}
    Y = Y{4.1 .. 7.5}
    Yes (0.00s cpu)

    ?- X::1.0..9.0, Y::5..7, impose_domain(X, Y).
    X = X{5 .. 7}
    Y = Y{5 .. 7}
    Yes (0.00s cpu)

    ?- X::1..3, Y::5..7, impose_domain(X, Y).
    No (0.00s cpu)

    ?- Y::1..5, impose_domain(3, Y).
    Y = Y{1 .. 5}
    Yes (0.00s cpu)

    ?- Y::1..5, impose_domain(6, Y).
    No (0.00s cpu)

    ?- Y::1..5, impose_domain(X, Y).
    Y = Y{1 .. 5}
    X = X{1 .. 5}
    Yes (0.00s cpu)
</PRE>
<H2>See Also</H2>
<A HREF="../../lib/ic_kernel/impose_min-2.html">impose_min / 2</A>, <A HREF="../../lib/ic_kernel/impose_max-2.html">impose_max / 2</A>, <A HREF="../../lib/ic_kernel/impose_bounds-3.html">impose_bounds / 3</A>, <A HREF="../../lib/ic_kernel/exclude-2.html">exclude / 2</A>, <A HREF="../../lib/ic_kernel/exclude_range-3.html">exclude_range / 3</A>
</BODY></HTML>
